<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="edge" />
    <meta content="elkan1788#gmail.com" name="author" />
    <link rel="shortcut icon" href="${base}/static/img/favicon.ico" />
    <title>管理后台-登录</title>
    <link href="${base}/static/css/admin-login.css" rel="stylesheet"/>
    <script src="${base}/static/js/jquery.min.js"></script>
    <script>
        var code ;
        function showCheck(a){
            var c = document.getElementById("JCodeCanvas");
            var ctx = c.getContext("2d");
            ctx.clearRect(0,0,1000,1000);
            ctx.fillStyle = "white";
            ctx.font = "100px 'Microsoft Yahei'";
            ctx.fillText(a,20,120);
        }

        function createCode(){
            code = "";
            var codeLength = 4;
            var selectChar = new Array(1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','j','k','l','m','n','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z');
            for(var i=0;i<codeLength;i++) {
                var charIndex = Math.floor(Math.random()*60);
                code +=selectChar[charIndex];
            }
            if(code.length != codeLength){
                createCode();
            }
            showCheck(code);
        }

        window.onload = function() {
            createCode();
        }

        function submitLoginFrm() {

            var act = $('#account').val();
            var pswd = $('#passwd').val();
            var vc = $('#verifycode').val();

            if(code.toUpperCase() != vc.toUpperCase()) {
                $('#verifycode').focus();
                $('#tipMsg').html('验证码不正确!').fadeIn('fast').fadeOut('slow');
                return false;
            }

            $.post('${base}/admin/checkLogin.do', {
                'account': act,
                'passwd': pswd
            }, function(data){
                if (data.ok) {
                    window.location.href = '${base}'+data.data;
                } else {
                    $('#account').focus();
                    $('#tipMsg').html(data.msg).fadeIn('fast').fadeOut(5000);
                    return false;
                }
            }, 'json');

            return false;
        }
    </script>
</head>
<body>
<div class="login">
    <div class="message">爱康健维-管理登录</div>
    <div id="darkbannerwrap"></div>
    <hr class="hr20">
    <hr class="hr5">
    <form id="loginForm" method="post" action="${base}/admin/checkLogin.do" onsubmit="return submitLoginFrm();">
        <dl>
            <dd class="user_icon">
                <input id="account" name="account" placeholder="用户名" required="" type="text"/>
            </dd>
            <hr class="hr5">
            <dd class="pwd_icon">
                <input id="passwd" name="passwd" placeholder="密码" required="" type="password"/>
            </dd>
            <hr class="hr5">
            <dd class="val_icon">
                <input id="verifycode" name="verifycode" placeholder="验证码" maxlength="4" required="" type="text" style="width:70%">
                <canvas class="JCodeImg" id="JCodeCanvas" onclick="createCode()">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
            </dd>
            <hr class="hr15">
            <input value="登录" style="width:100%;" type="submit">
            <hr class="hr20">
            <a onClick="alert('请联系管理员')">忘记密码</a>
            <hr class="hr20">
            <div style="height: 26px;">
                <div id="tipMsg" style="display: none;color: #ff4136;">

                </div>
            </div>
        </dl>
    </form>
</div>

<div class="copyright">© 2017 by <a href="#">i爱康健维</a> 版权所有</div>

</body>
</html>
